package cn.edu.hbsi.dao;

import cn.edu.hbsi.domain.Area;
import cn.edu.hbsi.domain.Driver;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface AreaDao
{
    //根据id查询地区信息
    @Results({
            @Result(id = true,property = "aId",column = "id"),
            @Result(property = "areaName",column = "areaname")
    })
    @Select("select * from de_area where id=#{aId}")
    public Area selectAreaByAId(@Param("aId") Integer aId);

    //查询某地区的所有司机信息
    @Results({
            @Result(id = true,property = "aId",column = "id"),
            @Result(property = "areaName",column = "areaname"),
            @Result(property = "drivers",column = "id",many = @Many(select = "cn.edu.hbsi.dao.DriverDao.selectDriverByAreaId"))
    })
    @Select("select * from de_area where areaname=#{areaName}")
    public Area selectDriversByAreaName(@Param("areaName") String areaName);
}
